<%-- 
    Document   : smsType1
    Created on : 11 Jan, 2013, 6:57:07 PM
    Author     : sagar
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="../common/script.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <%@include file="../common/title.jsp" %>
        <script type="text/javascript">
            $(function() {  
                $( "#appointmentDate" ).datetimepicker({dateFormat: 'dd-mm-yy',stepMinute:15, hourMin:8,hourMax:21,minDate:0});
            });
        </script>
        <script type="text/javascript">
            
            function selectSms(){
                var id=document.getElementById("centerId");
                var centreInfo = id.options[id.selectedIndex].text;
                centreName=centreInfo.replace(/[^A-Za-z]+/g, " ");
                centerContact=centreInfo.replace(/[^0-9+]+/g, " ");
 
                var doctorName=document.getElementById("doctorId").value;
                var appointmentDate=document.getElementById("appointmentDate").value;
                
                if(doctorName.length!=0){
                        var msBody="Dear ${customer.customerName}, This is to confirm the changed appointment. As per your request, you now have a scheduled appointment with Dr. "+doctorName + " at " +centreName+ " Centre on "+appointmentDate+".For any queries, call " +centreName+ "Centre ("+centerContact+"). Take care!";
                        document.getElementById("smsType12").value=msBody;
                }
                 else{
                     var msBody="Dear ${customer.customerName}, As per your request, you now have a scheduled appointment at " +centreName+ " Centre on "+appointmentDate+".For any queries, call " +centreName+ " Centre ("+centerContact+"). Take care!";
                     document.getElementById("smsType12").value=msBody;
                 }       
                
            }
        </script>
        <script type="text/javascript">
            
            var rules=new Array();
            rules[0]='appointmentDate|required|please Select appointment date';
            rules[1]='centerId|required|please Select center';
            
        </script>
    </head>
    <body style="margin:0; padding:0;" onLoad="yav.init('form1',rules,'inline');">
        <%@include file="../common/header.jsp" %>
        <%@include file="../common/menu.jsp" %>
        <div class="in_02">
            <form:form id="form1" name="form1"  method="POST">
            <fieldset>
                <legend>Sending SMS For - Advance/Postpone Appointment</legend>
                <table class="formTable">
                    <tr>
                        <td style="padding:5px 30px 1px 5px;"  >  <spring:message code="centerName"/>:<br/>
                            <select  id="centerId" name="centerId"  class="userInputMedium" onchange="selectSms();">
                                <option value="" label="-"></option>
                                <c:forEach items="${centerList}" var="list">
                                    <option value="${list.centerId}">${list.centerName} ~ ${list.phoneNumber} </option>
                                </c:forEach>
                            </select><br/>
                            <span id="errorsDiv_centerId"></span><br/>
                        </td>
                        <td style="padding:5px 30px 1px 5px;"><spring:message code="doctorName"/>:<br/>
                            <select  id="doctorId" name="doctorId"  class="userInputMedium" onchange="selectSms();">
                                <option value="" label="-"></option>
                                <c:forEach items="${doctorList}" var="list">
                                    <option value="${list.doctorName}">${list.doctorName} </option>
                                </c:forEach>
                            </select> 
                        </td>
                        <td>Appointment Date:<br/>
                            <input name="appointmentDate"  id="appointmentDate" class="userInputLarge" onchange="selectSms();"/>
                            <span id="errorsDiv_appointmentDate"></span><br/>
                        </td>
                    </tr>

                    <tr>
                        <td colspan="3"><b><span class="HeadingForSms">Advance/Postpone Appointment</span></b><br/><br/>
                            Message :<br/>
                            <textarea id="smsType12" name="smsType12"  value="${msBody}" class="TextAreaForSms" readonly=""/></textarea><br/>
                        <td>
                    </tr>
                    <tr>
                        <td><input type="submit" name="_finish" value="<spring:message code="button.sendSms"/>" onclick="return yav.performCheck('form1', rules, 'inline');"/></td>
                        <td><input type="submit" name="_cancel" value="<spring:message code="button.Cancel"/>" /></td>
                    </tr>
                </table>
            </fieldset>
            </form:form>
        </div>
    </body>
</html>
